package com.juku2024.juku.db.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.juku2024.juku.db.entity.HistoryEntity

@Dao
interface HistoryDao {

    @Query("SELECT * FROM history ORDER BY data DESC")
    fun queryHistoriesLiveData(): LiveData<List<HistoryEntity>>

    @Query("SELECT * FROM history ORDER BY data DESC")
    fun queryHistories(): List<HistoryEntity>?

    @Query("SELECT * FROM history WHERE videoId=:moveId")
    fun queryHistory(moveId: Long): HistoryEntity?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(history: HistoryEntity)

    @Query("DELETE FROM history")
    fun deleteAll()

    @Delete
    fun delete(entity: HistoryEntity)

    @Query("DELETE FROM history WHERE videoId=:videoId")
    fun delete(videoId: Long)

    @Delete
    fun delete(entities: List<HistoryEntity>): Int
}